<?php


namespace App\Transformers\Store;


use App\Models\LiveAnchor;
use App\Models\StoreServiceRecord;
use League\Fractal\TransformerAbstract;

class StoreServiceRecordTransformer extends TransformerAbstract
{
    public function transform(StoreServiceRecord $data)
    {
        return [
            'id' => $data->id,
            'sender_user_id' => $data->sender_user_id ?? "",
            'receiver_user_id' => $data->receiver_user_id ?? "",
            'nickname' => $data->nickname ?? "",
            'avatar' => $data->avatar ?? "",
            'news_num' => $data->news_num ?? "",
            'news_content' => $data->news_content ?? "",
            'news_type' => $data->news_type ?? "",
            'news_type_text' => $data->newsTypeEnum[$data->news_type] ?? "",
            'is_tourist' => $data->is_tourist ?? 0,
            'is_online' => $data->is_online ?? 0,
            'type' => $data->type ?? "",
            'type_text' => $data->typeEnum[$data->type] ?? "",
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }

}
